(function($){
	$.extend($.fn,{
		overlay:function(setting){
			var ps = $.extend({
				renderTo:$(document.body),
				cls:"",
				backgroundColor:'#000',
				opacity:'0.5',
				zIndex:'999'
			},setting);
			ps.renderTo = (typeof ps.renderTo == 'string' ? $(ps.renderTo) : ps.renderTo);
			var overlayDiv = $("<div></div>");
			if(ps.cls != ''){
				overlayDiv.addClass(ps.cls);
			}else{
				overlayDiv.css("background",ps.backgroundColor);
			}			
			
			
			resizeTO();
			overlayDiv.appendTo(ps.renderTo);
			$(window).resize(function(){
				resizeTO();
			})			
			function resizeTO(){
				var renderWidth = ps.renderTo.outerWidth();
				var renderHeight = ps.renderTo.outerHeight();
				var renderPosition = ps.renderTo.position();
				overlayDiv.width(renderWidth);
				overlayDiv.height(renderHeight);
				overlayDiv.css({'z-index':ps.zIndex,opacity:ps.opacity,position:'absolute',top:renderPosition.top,left:renderPosition.left});
			}
			return overlayDiv;
		},
		destroy:function(){
			this.remove();
		},
		minimize:function(){
			this.hide();
		},
		restore:function(){
			this.show();
		},
		setZindex:function(zIndex){
			this.css({"z-index":zIndex});
		}
	})
})(jQuery)
